package com.zlk.algorithm.algorithm.recursion;

import java.util.ArrayList;
import java.util.List;

/**
 * @program: algorithm
 * @ClassName PrintAllSubsquences
 * @description:打印一个字符串的全部子序列
 * @author: slfang
 * @create: 2024-03-25 14:15
 * @Version 1.0
 **/
public class PrintAllSubsquences {

    // 1  2  3  4  5  6
    //从前到后 依次拿子序列  eg: 12  123  13  134  15  16


    //打印一个字符串的全部子序列
    public List<String> PrintAllSubsquences(String str){
        char[] chars = str.toCharArray();
        List<String> result = new ArrayList<>();
        process1(result,0,chars,"");
        return result;
    }

    private void process1(List<String> result, int index, char[] chars, String path) {
        if(index==chars.length){
            result.add(path);
        }
        //不要当前index
        process1(result,index+1,chars,path);
        //要当前index
        process1(result,index+1,chars,path+String.valueOf(chars[index]));
    }

    //打印一个字符串的全部子序列，要求不要出现重复字面值的子序列  使用set





}
